package com.hieu.tripmanager;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;

@SuppressWarnings("deprecation")
public class MainActivity extends TabActivity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);

		final TabHost tabHost = getTabHost();

		TabSpec listTripSpec = tabHost.newTabSpec("My Trip");
		getLayoutInflater();
		final View view1 = LayoutInflater.from(this).inflate(
				R.layout.tab_trip_layout, null);
		Intent listTripIntent = new Intent(this, MyTripActivity.class);
		listTripSpec.setIndicator(view1);
		listTripSpec.setContent(listTripIntent);

		final TabSpec expensesSpec = tabHost.newTabSpec("Expense");
		getLayoutInflater();
		final View view2 = LayoutInflater.from(this).inflate(
				R.layout.tab_expenses_layout, null);
		Intent expensesIntent = new Intent(this, ExpensesActivity.class);
		expensesSpec.setIndicator(view2);
		expensesSpec.setContent(expensesIntent);

		TabSpec analysisSpec = tabHost.newTabSpec("Analysis");
		getLayoutInflater();
		final View view3 = LayoutInflater.from(this).inflate(
				R.layout.tab_analysis_layout, null);
		Intent analysisIntent = new Intent(this, AnalysisActivity.class);
		analysisSpec.setIndicator(view3);
		analysisSpec.setContent(analysisIntent);

		TabSpec settingSpec = tabHost.newTabSpec("Setting");
		getLayoutInflater();
		View view4 = LayoutInflater.from(this).inflate(
				R.layout.tab_setting_layout, null);
		Intent settingIntent = new Intent(this, SettingActivity.class);
		settingSpec.setIndicator(view4);
		settingSpec.setContent(settingIntent);

		TabSpec viewMapSpec = tabHost.newTabSpec("View Map");
		getLayoutInflater();
		View view5 = LayoutInflater.from(this).inflate(R.layout.tab_map_layout,
				null);
		Intent viewMapIntent = new Intent(this, ViewMapActivity.class);
		viewMapSpec.setIndicator(view5);
		viewMapSpec.setContent(viewMapIntent);

		tabHost.addTab(listTripSpec);
		tabHost.addTab(expensesSpec);
		tabHost.addTab(analysisSpec);
		tabHost.addTab(settingSpec);
		tabHost.addTab(viewMapSpec);

//		tabHost.setOnTabChangedListener(new OnTabChangeListener() {
//
//			@Override
//			public void onTabChanged(String tabId) {
//				// TODO Auto-generated method stub
//				if (tabId.equals("Expense")) {
//					LocalActivityManager manager = getLocalActivityManager();
//					manager.destroyActivity(tabId, true);
//					manager.startActivity(tabId, new Intent(
//							getBaseContext(), ExpensesActivity.class));
//				} else if (tabId.equals("Analysis")) {
//					LocalActivityManager manager = getLocalActivityManager();
//					manager.destroyActivity(tabId, true);
//					manager.startActivity(tabId, new Intent(
//							getBaseContext(), AnalysisActivity.class));
//				} else if (tabId.equals("Setting")) {
//					LocalActivityManager manager = getLocalActivityManager();
//					manager.destroyActivity(tabId, true);
//					manager.startActivity(tabId, new Intent(
//							getBaseContext(), SettingActivity.class));
//				} else if (tabId.equals("View Map")) {
//					LocalActivityManager manager = getLocalActivityManager();
//					manager.destroyActivity(tabId, true);
//					manager.startActivity(tabId, new Intent(
//							getBaseContext(), ViewMapActivity.class));
//				}
//			}
//		});
	}
}
